package jpademo.service;

import java.util.List;

import jpademo.model.Card;
import jpademo.model.Student;
import jpademo.repository.StudentRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentService {

	
    @Autowired
    private StudentRepository stuRepository;
    
    public void one2oneDemo()
    {
        Student s = new Student();
        s.setID("1");
        s.setName("Peter");
        s.setScore(100);
        s.setAge("12");
        
        Card card = new Card();
        card.setCardID("card1");
        card.setBalance(200);
        s.setCard(card);
        
        stuRepository.save(s);
        Student peter = stuRepository.findByName("Peter").get(0);
        System.out.println(peter.getCard().getCardID());
        System.out.println(peter.getCard().getBalance());
    	stuRepository.delete(s);
    }
}




    

   
